package com.meilele.dao.czh;

import com.meilele.entity.czh.FivePost;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface FivePostMapper {
    @Delete({
        "delete from five_post",
        "where post_id = #{postId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer postId);

    @Insert({
        "insert into five_post (post_id, post_name, ",
        "post_labelling, create_time, ",
        "revert_id, post_content,post_title)",
        "values (#{postId,jdbcType=INTEGER}, #{postName,jdbcType=VARCHAR}, ",
        "#{postLabelling,jdbcType=VARCHAR},#{postTitle,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{revertId,jdbcType=INTEGER}, #{postContent,jdbcType=LONGVARCHAR})"
    })
    int insert(FivePost record);

    int insertSelective(FivePost record);

    @Select({
        "select",
        "post_id, post_name, post_labelling, create_time, revert_id, post_content,post_title",
        "from five_post",
        "where post_id = #{postId,jdbcType=INTEGER}"
    })
    @ResultMap("com.meilele.dao.czh.FivePostMapper.ResultMapWithBLOBs")
    FivePost selectByPrimaryKey(Integer postId);

    /**装修设计的总数
     * @param
     * @return
     */
    @Select({
            "select",
            "count(post_id) from five_post",
            "where post_labelling = '装修设计'"
    })

   int selectByPrimarypostLabellinga();

    /**装修姜堰的总数
     * @param
     * @return
     */
    @Select({
            "select",
            "count(post_id) from five_post",
            "where post_labelling = '装修经验'"
    })

    int selectByPrimarypostLabellingb();

    /**装修日记的总数
     * @param
     * @return
     */
    @Select({
            "select",
            "count(post_id) from five_post",
            "where post_labelling = '装修日记'"
    })

    int selectByPrimarypostLabellingc();

    /**晒新家的总数
     * @param
     * @return
     */
    @Select({
            "select",
            "count(post_id) from five_post",
            "where post_labelling = '晒新家'"
    })
    int selectByPrimarypostLabellingd();

    /**装修设计查询
     * @param firstPage
     * @param resultPage
     * @return
     */
    @Select({
            "select",
            "post_id, post_name,post_title, post_labelling, create_time, revert_id, post_content",
            "from five_post",
            "where post_labelling = '装修设计' limit #{firstPage},#{resultPage}"
    })
    @ResultMap("com.meilele.dao.czh.FivePostMapper.ResultMapWithBLOBs")
    List<FivePost> selectByPrimaryDesca(@Param("firstPage") int firstPage, @Param("resultPage") int resultPage);

    /**装修经验的查询
     * @param firstPage
     * @param resultPage
     * @return
     */
    @Select({
            "select",
            "post_id, post_name,post_title, post_labelling, create_time, revert_id, post_content",
            "from five_post",
            "where post_labelling = '装修经验' limit #{firstPage},#{resultPage}"
    })
    @ResultMap("com.meilele.dao.czh.FivePostMapper.ResultMapWithBLOBs")
    List<FivePost> selectByPrimaryDescb(@Param("firstPage") int firstPage, @Param("resultPage") int resultPage);

    /**装修日记查询
     * @param firstPage
     * @param resultPage
     * @return
     */
    @Select({
            "select",
            "post_id, post_name,post_title, post_labelling, create_time, revert_id, post_content",
            "from five_post",
            "where post_labelling ='装修日记' limit #{firstPage},#{resultPage}"
    })
    @ResultMap("com.meilele.dao.czh.FivePostMapper.ResultMapWithBLOBs")
    List<FivePost> selectByPrimaryDescc(@Param("firstPage") int firstPage, @Param("resultPage") int resultPage);

    /**晒新家查询
     * @param firstPage
     * @param resultPage
     * @return
     */
    @Select({
            "select",
            "post_id, post_name,post_title, post_labelling, create_time, revert_id, post_content",
            "from five_post",
            "where post_labelling ='晒新家' limit #{firstPage},#{resultPage}"
    })
    @ResultMap("com.meilele.dao.czh.FivePostMapper.ResultMapWithBLOBs")
    List<FivePost> selectByPrimaryDescd(@Param("firstPage") int firstPage, @Param("resultPage") int resultPage);

    int updateByPrimaryKeySelective(FivePost record);

    @Update({
        "update five_post",
        "set post_name = #{postName,jdbcType=VARCHAR},",
          "post_labelling = #{postLabelling,jdbcType=VARCHAR},",
            "post_title = #{postTitle,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "revert_id = #{revertId,jdbcType=INTEGER},",
          "post_content = #{postContent,jdbcType=LONGVARCHAR}",
        "where post_id = #{postId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(FivePost record);

    @Update({
        "update five_post",
        "set post_name = #{postName,jdbcType=VARCHAR},",
          "post_labelling = #{postLabelling,jdbcType=VARCHAR},",
            "post_title = #{postTitle,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "revert_id = #{revertId,jdbcType=INTEGER}",
        "where post_id = #{postId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(FivePost record);



       @Select({
            "select",
            "post_id, post_name,post_title, post_labelling, create_time, revert_id, post_content",
            "from five_post limit #{firstPage},#{resultPage}"
    })
    @ResultMap("com.meilele.dao.czh.FivePostMapper.ResultMapWithBLOBs")
    List<FivePost> selectByPrimaryAll(@Param("firstPage")int firstPage,@Param("resultPage")int resultPage);


    @Select({
            "select",
            "post_id, post_name,post_title, post_labelling, create_time, revert_id, post_content",
            "from five_post"
    })
    @ResultMap("com.meilele.dao.czh.FivePostMapper.ResultMapWithBLOBs")
    List<FivePost> selectByPrimaryAlla();



    @Select({
            "select",
            "count(post_id) from five_post"
    })
    int findallcount();


}